#pragma once
#include "voe_base.h"
#include "voe_hardware.h"
#include "voe_errors.h"
#include "voe_file.h"
#include "voe_volume_control.h"
#include "vie_base.h"
#include "vie_capture.h"
#include "vie_errors.h"
#include "vie_file.h"
#include "vie_render.h"
#include "vie_network.h"
#include "vie_rtp_rtcp.h"
#include "vie_codec.h"

#include <QtGui/QApplication>
#include <QMessageBox>

#include "ErrorMessage.h"

#define ERROR_MESSAGE CErrorMessage::getErrorMessage
#define EMPTY ""
#define VOE_LOGFILE "voice_trace.txt"
#define VIE_LOGFILE "video_trace.txt"

class CClientEngine
{
public:
	CClientEngine(void);
	~CClientEngine(void);

	void create();
	int setConnection(QString port, QString ip, HWND localHWND = 0, HWND remoteHWND = 0);
	void endConnection();
	void testWebcam(HWND hwnd);
	void endTestWebcam();
	void destroy();
	void setRecordingDevice(int id);
	void setPlayoutDevice(int id);
	void setCaptureDevice(int id);
	int getNumOfPlayoutDevices();
	int getNumOfCaptureDevices();
	int getNumOfRecordingDevices();
	void setPlayoutVolume(int value);
	void setMicVolume(int value);
	int getPlayoutVolume();
	int getMicVolume();
	bool getVideoState();
	QString getLocalIp();


	QStringList CClientEngine::GetVideoDeviceList();
	QStringList CClientEngine::GetRecordingDeviceList();
	QStringList CClientEngine::GetAudioDeviceList();

	webrtc::VoiceEngine* getVoiceEngine(void);
	webrtc::VoEBase* getVoEBase(void);
private:
	webrtc::VoiceEngine* voe;
	webrtc::VideoEngine* vie;
	webrtc::VoEBase* voeBase;
	webrtc::ViEBase* vieBase;
	webrtc::ViECapture* vieCapture;
	webrtc::ViERender* vieRender;
	webrtc::VoEHardware* voeHardware;
	webrtc::ViECodec* vieCodec;
	webrtc::VideoCodec videoCodec;
	webrtc::ViENetwork* vieNetwork;
	webrtc::VoEVolumeControl* voeVolumeControl;

	// ******************************************************************************************************************
	// class data
	// ******************************************************************************************************************
	char* chRemoteIp;
	int* iRemotePort;
	int ch;
	int vch;
	bool videoDisable;
	int captureId;
	int status; // variable for control functions output
	int recordingDeviceId;
	int playoutDeviceId;
	int captureDeviceId;
	int errorCode;

	QByteArray tempCharIp;
};

